<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>管理员管理-有点</title>
<link rel="stylesheet" type="text/css" href="<?php echo Url::base(); ?>/resource/css.css">
<link rel="stylesheet" type="text/css" href="<?php echo Url::base(); ?>/resource/pageGroup.css">
<script type="text/javascript" src="<?php echo Url::base(); ?>/resource/jquery.js"></script>
<script type="text/javascript" src="<?php echo Url::base(); ?>/resource/jquery-1.js"></script>

<script src="<?php echo Url::base();?>jquery.min.js" type="text/javascript"></script>
<script src="<?php echo Url::base(); ?>jquery.uploadify.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="<?php echo Url::base(); ?>uploadify.css">

<script charset="utf-8" src="<?php echo Url::base();?>kindeditor-4.1.7/kindeditor.js"></script>
<script charset="utf-8" src="<?php echo Url::base();?>kindeditor-4.1.7/lang/zh_CN.js"></script>
<script charset="utf-8" src="<?php echo Url::base();?>kindeditor-4.1.7/plugins/code/prettify.js"></script>
<!-- <script type="text/javascript" src="js/page.js" ></script> -->
</head>



<link rel="stylesheet" type="text/css" href="<?php echo Url::base(); ?>/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="<?php echo Url::base(); ?>/themes/icon.css">
<script type="text/javascript" src="<?php echo Url::base(); ?>/jquery.easyui.min.js"></script>
<script>
KindEditor.ready(function(K) {
	var editor1 = K.create('textarea[name="content1"]', {
		cssPath : '<?php echo Url::base();?>kindeditor-4.1.7/plugins/code/prettify.css',
		uploadJson : '<?php echo Url::base();?>kindeditor-4.1.7/php/upload_json.php',
		fileManagerJson : '<?php echo Url::base();?>kindeditor-4.1.7/php/file_manager_json.php',
		allowFileManager : true,
		afterCreate : function() {
			var self = this;
			K.ctrl(document, 13, function() {
				self.sync();
				K('form[name=example]')[0].submit();
			});
			K.ctrl(self.edit.doc, 13, function() {
				self.sync();
				K('form[name=example]')[0].submit();
			});
		}
	});
	prettyPrint();
});
</script>
<?php
if($action=="add"){?>
<form method="post" action="<?php echo Url::base(); ?>index.php/productm/addProduct">
	<?php
}else{?>
<form method="post" action="<?php echo Url::base(); ?>index.php/productm/updateProduct">
	<?php  }
	?>

	商品标题:<input type="text" maxlength="20" name="title"><br>
	原价:<input type="number"  name="OriginalPrice"><br>
	重量:<input type="number"  name="weight"><br>
	默认运费: <input type="number"  name="expressDefault"><br>
	主图:
	<input id="file_upload" name="name" type="file" multiple="true"><br>

	次图
	<input id="file_upload1" name="name" type="file" multiple="true"><br>
	次图
	<input id="file_upload2" name="name" type="file" multiple="true"><br>
	次图
	<input id="file_upload3" name="name" type="file" multiple="true"><br>
	次图
	<input id="file_upload4" name="name" type="file" multiple="true"><br>
	次图
	<input id="file_upload5" name="name" type="file" multiple="true"><br>
	活动列表:
	<?php foreach($product['active']  as $key=>$val){?>
	<input type="checkbox" name="active[]" value="<?php echo $val['id'];?>"><?php echo $val['name'];?>
	<?php }?>
	<br>
	标签列表:
<select name="brand" id="brand">

			
		</select>

		<br>
		门店自提:<input type="radio" checked value="1" name="isget"/>可以<input type="radio" value="0" name="isget"/>不可以
		<br>
		门店配送:<input type="radio" checked value="1" name="isstore"/>可以<input type="radio" value="0" name="isstore"/>不可以
		<br>
		是否可以用优惠券:<input type="radio" checked value="1" name="iscoupon"/>可以<input type="radio" value="0" name="iscoupon"/>不可以
		<br>选择产品品牌:
		<span id="brandlist"></span>
		<br>
		配送快递方式:
		<select id="express" name="express">
			<?php foreach($product['express']  as $key=>$val){?>
			<option value="<?php  echo $val['id'];?>"><?php  echo $val['name'];?></option>
			<?php } ?>
		</select>
		城市选择:
		<select name="province"  id="province" onchange="getCity(this)">
			<?php foreach($product['china']  as $key=>$val){?>
			<option value="<?php  echo $val['Id'];?>"><?php  echo $val['Name'];?></option>
			<?php } ?>
		</select>

		<select id="city" name="city">

		</select>
		如果选择中国 那么默认为0 全国统一邮费
		<input type="button" value="添加" onclick="addTemplate(this)">

		<br>


		<br>
		默认价格<input type="text" name="pricedefault">
		<br>
		名称<input type="text" name="specificationsname[]" /> 名称型号<input type="text" name="model[]" /> <input type="button" onclick="add(this)" value="添加">



		<br>
		配置商品价格: <font color="red"> 配置的型号必须在上面的型号要一致否则无法查询到价格 </font>
		<br>
		如果有门店配送和自提需要添加配送模版:<input  id="cc" class="easyui-combogrid" style="width:250px" data-options="
			panelWidth: 500,
			idField: 'id',
			textField: 'address',
			rownumbers:true,singleSelect:true,url:'<?php echo Url::base(); ?>index.php/storem/getData',method:'get',pagination:true,
			
			method: 'get',
			columns: [[
				{field:'id',width:80,title:'主键'},
				{field:'provinceshow',width:100,title:'省份'},
				{field:'cityshow',width:100,title:'城市'},
				{field:'address',width:180,title:'地址'},
				{field:'longitude',width:80,title:'经度'},
				{field:'latitude',width:100,title:'纬度'},
				{field:'isget',width:100,title:'是否门店自提',formatter: function(value,row,index){
				
				if (row.isget == 1){
					return '支持';
				} else {
					return '不支持';
				}
				}},
				{field:'isstore',width:180,title:'是否门店配送',align:'right',formatter: function(value,row,index){
				
				if (row.isstore == 1){
					return '支持';
				} else {
					return '不支持';
				}
				}}
			]],
			fitColumns: true
		">

		<br>
			
		
		<br>
		<script type="text/javascript">
			//<input type="checkbox" name="label[]" value=" ">

			function getLabel(obj){
					$.ajax({

						type: 'POST',
						url: '<?php echo Url::base(); ?>index.php/labelm/getlist?model='+ $(obj).val(),
						success: function(data){
							console.log(data)
							$("#list").html("")
							for(var i = 0 ;i<data.length;i++){
								$("#list").append('<input type="checkbox" name="label[]" value="'+data[i].id+'">'+data[i].model)

							}

						} ,
						dataType: "json"

					});

					$.ajax({

						type: 'POST',
						url: '<?php echo Url::base(); ?>index.php/brandm/getlist?model='+ $(obj).val(),
						success: function(data){
							console.log(data)
							$("#brand").html("")
							for(var i = 0 ;i<data.length;i++){
								$("#brand").append('<option  value="'+data[i].id+'">'+data[i].name+'</option>')

							}

						} ,
						dataType: "json"

					});
				}
			$(function(){
				console.log($("select[name='type']").val())
				getLabel($("select[name='type']"))
			})

				function addModel(obj){


				var val = $('#cc').combogrid('getValue');

				if(val == ""){
					alert("请选择配送门店")
					return 
				}
				var g = $('#cc').combogrid('grid');	// get datagrid object
				var r = g.datagrid('getSelected');	// get the se
				
				$(obj).before('<br>库存:<input name="store[]" type="text">名称型号<input name="modelname[]" type="text">名称型号<input name="modelname1[]" type="text">名称型号<input name="modelname2[]" type="text"> 价格<input type="text" name="modelprice[]" /> 门店地址<input type="text" value="'+r.address+'" readonly="readonly"/><input type="hidden" name="modeladdress[]" value="'+r.id+'" readonly="readonly"/> ')
			}
			function add(obj){
				$(obj).before('<br>名称<input type="text" name="specificationsname[]" /> 名称型号<input type="text" name="model[]" /> ')
			}
		</script>
		<br>


		分类:

		<script>

		function addTemplate(obj){
			try{

				var city = 0;

				if($("#province").val()=="0"&&$("input[name='province1[]']").length>0){
					city = "";

					alert("添加了其他城市配送价格不能添加默认");
					return
				}

				if($("#province").val()=="0"){

					$("input[name='province1[]']").each(function(key,value){
						
						if($(value).val()=="中国"){
							alert("已经包含默认运费请不要重复添加");
							return 
						}
					})
					
				}
				var cityid ="";
				if($("#province").val()=="0"||$("#city").val()==null){

					city = "";
					cityid =""
				}else{
					cityid = $("#city").val();
					city = document.getElementById("city").options[document.getElementById("city").options.selectedIndex].text;
				}
				if($("#city").val()!=""&&$("#city").val()=="0"){
						alert("不能选择中国");
							return
				}

				var flag = false;
				if($("#province").val()!="0"){
					$("input[name='province1[]']").each(function(key,value){

						if($(value).val()=="中国"){

							alert("已经包含默认运费请不要重复添加");
							flag = true;
							return
						}
					})
				}
				if(flag) {
					return
				}
				var item = '<div><br><input type="text" name="province1[]" value="'+document.getElementById("province").options[document.getElementById("province").options.selectedIndex].text+'"  readonly="readonly" /><input type="hidden" name="province[]" value="'+$("#province").val()+'"  readonly="readonly" />' +
					'<input type="text"  name="city1[]"  value="'+city+'"    readonly="readonly" /><input type="hidden" name="city[]"   value="'+cityid+'"    readonly="readonly" />' +
					'运费<input type="text" name="postFee[]"   />超过多少公斤开始计算费用' +
					'<input type="text" name="morethan[]"   /> 每公斤多少RMB<input type="text" name="price[]"   /><input type="hidden" name="templateId[]" value="'+$("#express").val()+'"  readonly="readonly" /> <input type="button" value="删除" onclick="delElement(this)"></div>';

				$(obj).after(item)
			}catch(e){
				console.log(e)
			}

		}
		function getCity(obj){
			$.ajax({

				type: 'POST',
				url: '<?php echo Url::base(); ?>index.php/chinam/getCity?id='+ $(obj).val(),
				success: function(data){
					$("#city").html("")
					var size =  data.length;
					for(var i = 0; i < size;i++){
						var varItem = new Option(data[i].Name,data[i].Id);
						document.getElementById("city").options.add(varItem);
					}
				} ,
				dataType: "json"

			});
		}
		function change(obj){
//				alert($(obj).val())
$.ajax({

	type: 'POST',
	url: '<?php echo Url::base(); ?>index.php/categorym/category?parentId='+ $(obj).val(),
	success: function(data){
		$("#classification").html("")
		var size =  data.length;
		for(var i = 0; i < size;i++){
			var varItem = new Option(data[i].name,data[i].id);
			document.getElementById("classification").options.add(varItem);
		}
	} ,
	dataType: "json"

});
}
</script>
<select name="category" onchange="change(this)">
	<?php foreach($product['category']  as $key=>$val){?>
	<option value="<?php  echo $val['id'];?>"><?php  echo $val['name'];?></option>
	<?php }?>
</select>

<select id="classification" name="classification">

</select>
<br>
<select name="type" onchange="getLabel(this)">
	<option value="在线商城" selected>
		在线商城
	</option>
	<option value="餐饮娱乐">

		餐饮娱乐
	</option>
	<option value="家政服务">

		家政服务
	</option>
	<option value="美容美发">

		美容美发
	</option>
	<option value="教育培训">

		教育培训
	</option>
	<option value="汽车房产">

		汽车房产
	</option>
	<option value="家居建材">

		家居建材
	</option>
	<option value="二手市场">

		二手市场
	</option>

</select>
描述内容<textarea name="content1" style="width:700px;height:200px;visibility:hidden;"></textarea>
<input type="hidden" attr="file_upload"  name="mainpic[]"><br>

<input type="hidden"  attr="file_upload1" name="mainpic[]"><br>
<input type="hidden"   attr="file_upload2"  name="mainpic[]"><br>
<input type="hidden"   attr="file_upload3" name="mainpic[]"><br>
<input type="hidden"    attr="file_upload4" name="mainpic[]"><br>

<input type="hidden"    attr="file_upload5" name="mainpic[]"><br>

<input type="submit"    ><br>

<br>
</form>
<script type="text/javascript">
<?php $timestamp = time();?>

$(function() {
	$('#file_upload').uploadify({

		'formData'     : {
			'timestamp' : '<?php echo $timestamp;?>',
			'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
		},
		'swf'      : '<?php echo Url::base(); ?>uploadify.swf',
		'uploader' : '<?php echo Url::base(); ?>index.php/productm/upload',
		'onUploadSuccess':function(file,data,response){
			if(data== 'false'){
				alert("图片格式不正确请检查")
			}else{
				alert("上传成功")
				$("input[attr='file_upload']").val(data)

			}}

		});

	$('#file_upload1').uploadify({

		'formData'     : {
			'timestamp' : '<?php echo $timestamp;?>',
			'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
		},
		'swf'      : '<?php echo Url::base(); ?>uploadify.swf',
		'uploader' : '<?php echo Url::base(); ?>index.php/productm/upload',
		'onUploadSuccess':function(file,data,response){
			if(data== 'false'){
				alert("图片格式不正确请检查")
			}else{
				alert("上传成功")
				$("input[attr='file_upload1']").val(data)

			}}
		});

	$('#file_upload2').uploadify({

		'formData'     : {
			'timestamp' : '<?php echo $timestamp;?>',
			'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
		},
		'swf'      : '<?php echo Url::base(); ?>uploadify.swf',
		'uploader' : '<?php echo Url::base(); ?>index.php/productm/upload',
		'onUploadSuccess':function(file,data,response){
			if(data== 'false'){
				alert("图片格式不正确请检查")
			}else{
				alert("上传成功")
				$("input[attr='file_upload2']").val(data)

			}}
		});
	$('#file_upload3').uploadify({

		'formData'     : {
			'timestamp' : '<?php echo $timestamp;?>',
			'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
		},
		'swf'      : '<?php echo Url::base(); ?>uploadify.swf',
		'uploader' : '<?php echo Url::base(); ?>index.php/productm/upload',
		'onUploadSuccess':function(file,data,response){
			if(data== 'false'){
				alert("图片格式不正确请检查")
			}else{
				alert("上传成功")
				$("input[attr='file_upload3']").val(data)

			}}
		});
	$('#file_upload4').uploadify({

		'formData'     : {
			'timestamp' : '<?php echo $timestamp;?>',
			'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
		},
		'swf'      : '<?php echo Url::base(); ?>uploadify.swf',
		'uploader' : '<?php echo Url::base(); ?>index.php/productm/upload',
		'onUploadSuccess':function(file,data,response){
			if(data== 'false'){
				alert("图片格式不正确请检查")
			}else{
				alert("上传成功")
				$("input[attr='file_upload4']").val(data)

			}}
		});
	$('#file_upload5').uploadify({

		'formData'     : {
			'timestamp' : '<?php echo $timestamp;?>',
			'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
		},
		'swf'      : '<?php echo Url::base(); ?>uploadify.swf',
		'uploader' : '<?php echo Url::base(); ?>index.php/productm/upload',
		'onUploadSuccess':function(file,data,response){
			if(data== 'false'){
				alert("图片格式不正确请检查")
			}else{
				alert("上传成功")
				$("input[attr='file_upload5']").val(data)

			}}
		});
});
</script>
</body></html>